<!-- 提示弹窗 -->
<template>
	<view class='cu-modal' :class='{show: show}'>
		<view class='modal'>
			<view class='alert-title'>{{params.title}}</view>
			<view class='alert-content'>{{params.content}}</view>
			<view class='alert-foot'>
				<view class='alert-btn default' @click='handleClose'>{{params.leftBtn}}</view>
				<view class='alert-btn blue' @click='handleConfirm'>{{params.rightBtn}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false, 
				params: {},
			}
		},
		methods: {
			open(params) {
				this.params.title = params.title || '提示'; //标题
				this.params.content = params.content || ''; //内容
				this.params.leftBtn = params.leftBtn || '取消'; //取消按钮
				this.params.rightBtn = params.rightBtn || '确认'; //确认按钮
				this.params.success = params.success || null; //确认方法回调
				this.params.close = params.close || null; //取消方法回调
				this.show = true;
			},
			close() {
				this.show = false;
			},
			handleClose() {
				if(this.params.close) {
					this.params.close()
				}
				this.close()
			},
			handleConfirm() {
				if(this.params.success) {
					this.params.success()
				}
				this.close()
			}
		}
	}
</script>

<style scoped lang="scss">
	.modal {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%,-50%);
		width: 638rpx;
		border-radius: 6rpx;
		background: #FFFFFF;
		text-align: left;
		padding: 68rpx 0 62rpx 0;
		
		.alert-title {
			font-size: 32rpx;
			font-weight: 500;
			color: #3D3D3D;
			text-align: center;
		}
		
		.alert-content {
			font-size: 28rpx;
			color: #999999;
			margin-top: 20rpx;
			text-align: center;
		}
		
		.alert-foot {
			padding: 86rpx 0 0 0;
			display: flex;
			align-items: center;
			justify-content: center;
			
			.alert-btn {
				width: 200rpx;
				height: 60rpx;
				border-radius: 8rpx;
				font-size: 28rpx;
				font-weight: 500;
				display: flex;
				align-items: center;
				justify-content: center;
				
				&.default {
					border: 2rpx solid #ff0000;
					color: #ff0000;
					margin-right: 40rpx;
				}
				
				&.blue {
					background: linear-gradient(90deg, #ff0000 0%, #ff0000 100%);
					color: #FFFFFF;
				}
			}
		}
		
	}
</style>